import React, { Component } from 'react';
import "../MIUIcss/play.scss"
import { NavBar, Space, Toast } from "antd-mobile";
import { connect } from "react-redux";
import {SUCCESS_ORDER} from "../store/action-type/dingdan"
import {removePrd} from "../serves/LodaCart"
 class Wxplay extends Component {
    constructor(props){
        super(props)
        console.log(props);
        this.history =props.history
        this.id = props.location.state.id
        this.state=this.props.order.find(item=>item.id==this.id)
        this.dispatch =this.props.dispatch
        
    }
    
  render() {
    if (!this.state) {
      this.history.push({ pathname: "/cart" });
      return null
    }
    return (
      <div className="wxPlay">
        <NavBar
          className="playTabBer"
          backArrow={false}
          back={"取消"}
          children={"确认支付"}
          onBack={()=>{
              this.history.replace({
                pathname: "/Cart/resolvd",
                state: { id: this.id },
              });
          }}
        />
        <p className="ddhao">小米科技{this.state.orderNumber}号订单</p>
        <p className="price">￥{this.state.money}</p>
        <div className="shoukuan">
          <span>收款方</span>
          <span>小米科技有限公司</span>
        </div>
        <div className="zhifu" onClick={()=>{
            this.dispatch({ type: SUCCESS_ORDER, index: this.id });
            
            // this.history.replace({ pathname: "/Cart/success",state:{id:this.id} });
            setTimeout(() => {
                this.history.replace({
                  pathname: "/Cart/success",
                  state: { id: this.id },
                });
                this.state.data.forEach(item=>{
                  removePrd(item.id)
                })
                
            }, 1000);
        }
        }>立即支付</div>
        <p className="chengbao">支付安全由谁担保</p>
      </div>
    );
  }
}
export default connect(store=>{
    return store

})(Wxplay); 